package com.txhy.certificatechain.ui.fragment.friend;

import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.txhy.certificatechain.R;
import com.txhy.certificatechain.presenter.base.BasePresenter;
import com.txhy.certificatechain.ui.activity.base.BaseFragment;
import com.txhy.certificatechain.ui.adapter.FragPagerAdapter;
import com.txhy.certificatechain.utils.UIUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/*
 * -----------------------------------------------------------------
 * Copyright (C) 2018-2030, by your company, All rights reserved.
 * -----------------------------------------------------------------
 * 文    件: FriendsFragment.java
 * 作    者: 侯建军
 * 版    权: 1.0.0
 * 描    述: 好友片段
 * 创建时间: 2018/9/20 9:40
 * 更新时间：2018/9/20 9:40
 * -----------------------------------------------------------------
 * 2018/9/20 9:40: 创建 FriendsFragment.java (侯建军);
 * -----------------------------------------------------------------
 */
public class FriendsFragment extends BaseFragment {
    @BindView(R.id.tv_title)
    TextView tv_title;

    @BindView(R.id.im_left)
    ImageView im_left;

    @BindView(R.id.image_function)
    ImageView image_function;

    @BindView(R.id.image_function_two)
    ImageView image_function_two;
    @BindView(R.id.tv_one)
    TextView tv_one;

    @BindView(R.id.tv_two)
    TextView tv_two;
    @BindView(R.id.view_one)
    View view_one;

    @BindView(R.id.view_two)
    View view_two;
    @BindView(R.id.vp_myCer)
    ViewPager vp_myCer;
    private List<Fragment> mFragments = new ArrayList<>();
    @Override
    protected BasePresenter createPresenter() {
        return null;
    }
    public static FriendsFragment newInstance() {
        return new FriendsFragment();
    }
    //加载布局文件
    @Override
    protected int provideContentViewId() {
        return R.layout.frag_find;
    }

    @Override
    public void initView(View rootView) {
        super.initView(rootView);
        im_left.setVisibility(View.INVISIBLE);
        tv_title.setText(UIUtils.getString(R.string.wodehaoyou));
        tv_one.setText(UIUtils.getString(R.string.haoyouliebiao));
        tv_two.setText(UIUtils.getString(R.string.tongxunlu));
        mFragments.add(com.txhy.certificatechain.ui.fragment.friend.FriendListFragment.newInstance());
        mFragments.add(com.txhy.certificatechain.ui.fragment.bottomnavigation.FriendListFragment.newInstance());
        vp_myCer.setAdapter(new FragPagerAdapter(getChildFragmentManager(), mFragments));
        vp_myCer.setCurrentItem(0, false);
        vp_myCer.setOffscreenPageLimit(2);
        image_function.setVisibility(View.VISIBLE);
        image_function_two.setVisibility(View.VISIBLE);
        image_function.setImageResource(R.mipmap.addfriends);
        image_function_two.setImageResource(R.mipmap.searchfriends);
    }

    @OnClick({ R.id.ll_one, R.id.ll_two,R.id.image_function,R.id.image_function_two})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_one:
                vp_myCer.setCurrentItem(0);
                view_one.setVisibility(View.VISIBLE);
                view_two.setVisibility(View.INVISIBLE);
                tv_one.setTextColor(UIUtils.getColor(R.color.ed584c));
                tv_two.setTextColor(UIUtils.getColor(R.color.text423b));
                break;
            case R.id.ll_two:
                vp_myCer.setCurrentItem(1);
                view_one.setVisibility(View.INVISIBLE);
                view_two.setVisibility(View.VISIBLE);
                tv_two.setTextColor(UIUtils.getColor(R.color.ed584c));
                tv_one.setTextColor(UIUtils.getColor(R.color.text423b));
                break;
            case R.id.image_function:
//                startActivity(new Intent(getActivity(),SearchFriendsActivity.class));
                break;
            case R.id.image_function_two:
                break;
        }
    }
}

